package com.qitianyong.selfclass;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.model.ModelLoaderFactory;
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
import com.bumptech.glide.signature.ObjectKey;
import com.gkusbsdk.SZUSBFile;

import java.nio.ByteBuffer;

/**
 * Created by gy on 2018/3/22.
 */

public class UvcModelLoader  implements ModelLoader<SZUSBFile, ByteBuffer> {
    @Nullable
    @Override
    public LoadData<ByteBuffer> buildLoadData(@NonNull SZUSBFile gkusbFile, int width, int height, @NonNull Options options) {
        return new LoadData<>(new ObjectKey(new String(gkusbFile.__name)), new UvcDataFetcher(gkusbFile));
    }


    @Override
    public boolean handles(@NonNull SZUSBFile gkusbFile) {
        return true;
    }
    static class  UvcModelLoaderFactory implements ModelLoaderFactory<SZUSBFile, ByteBuffer> {

        @Override
        public ModelLoader<SZUSBFile, ByteBuffer> build(MultiModelLoaderFactory unused) {
            return new UvcModelLoader();
        }

        @Override
        public void teardown() {
            // Do nothing.
        }
    }

}
